﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace leviathan_mapeditor
{
    public partial class Form1 : Form
    {
        MainForm main;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            main = new MainForm();
            panel1.Visible = false;
        }

        private void újKalandToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form ns = new leviathan_mapeditor.newScenario.newScenario(ref main);
            ns.Activate();
            ns.Visible = true;
            ns.BringToFront();

            panel1.Visible = true;
        }

        private void kalandBetöltéseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form ls = new leviathan_mapeditor.loadScenario.loadForm(ref main);
            ls.Activate();
            ls.Visible = true;
            ls.BringToFront();

            panel1.Visible = true;
        }

        private void mentésToolStripMenuItem_Click(object sender, EventArgs e)
        {
            main.saveScenario();
        }

        private void kilépésToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            MainForm.mission s;
            s.desc = description.Text;
            s.left = left.Text;
            s.right = right.Text;
            s.fight = fight.Text;
            s.search = search.Text;

            main.updateList(Convert.ToInt32(numericUpDown1.Value), s);
            refreshForm();
        }

        private void refreshForm()
        {
            label3.Text = main.getName();
            label9.Text = main.getAllNum().ToString();

            MainForm.mission s;
            s = main.getActMission();
            description.Text = s.desc;
            left.Text = s.left;
            right.Text = s.right;
            fight.Text = s.fight;
            search.Text = s.search;
            
            numericUpDown1.Value = main.getActMissionNum();
        }

        private void newleftnewleft_Click(object sender, EventArgs e)
        {
            MainForm.mission s;
            s.desc = description.Text;
            s.left = left.Text;
            s.right = right.Text;
            s.fight = fight.Text;
            s.search = search.Text;

            main.toMission("left", s);

            refreshForm();
        }

        private void newright_Click(object sender, EventArgs e)
        {
            MainForm.mission s;
            s.desc = description.Text;
            s.left = left.Text;
            s.right = right.Text;
            s.fight = fight.Text;
            s.search = search.Text;

            main.toMission("right", s);

            refreshForm();
        }

        private void newfight_Click(object sender, EventArgs e)
        {
            MainForm.mission s;
            s.desc = description.Text;
            s.left = left.Text;
            s.right = right.Text;
            s.fight = fight.Text;
            s.search = search.Text;

            main.toMission("fight", s);

            refreshForm();
        }

        private void newsearch_Click(object sender, EventArgs e)
        {
            MainForm.mission s;
            s.desc = description.Text;
            s.left = left.Text;
            s.right = right.Text;
            s.fight = fight.Text;
            s.search = search.Text;

            main.toMission("search", s);

            refreshForm();
        }

        private void Form1_rePaint(object sender, EventArgs e)
        {
            if (main.getStatus() == mainState.ok)
                refreshForm();
        }

        private void Form1_rePaint(object sender, PaintEventArgs e)
        {
            if (main.getStatus() == mainState.ok)
                refreshForm();
        }

    }
}
